package com.littcore.saap.message.module;

import akka.actor.UntypedActor;

import com.littcore.saap.message.biz.IMessageBizService;
import com.littcore.saap.message.bo.MessageChannelBo;




/**
 * .
 * 
 * <pre><b>描述：</b>
 *    
 * </pre>
 * 
 * <pre><b>修改记录：</b>
 *    
 * </pre>
 * 
 * @author <a href="mailto:littcai@hotmail.com">蔡源</a>
 * @since 2015年10月27日
 * @version 1.0
 */
public class MessageActor extends UntypedActor {

  private IMessageBizService messageBizService;
  
  public MessageActor(IMessageBizService messageBizService)
  {
    this.messageBizService = messageBizService;
  }

  /* (non-Javadoc)
   * @see akka.actor.UntypedActor#onReceive(java.lang.Object)
   */
  @Override
  public void onReceive(Object obj) throws Exception
  {
    if(obj instanceof MessageChannelBo)
    {
      MessageChannelBo messageChannel = (MessageChannelBo)obj;
      
      switch (messageChannel.getChannel())
      {
        case "email": 
          messageBizService.sendEmail(messageChannel); 
          break;
        case "sms":
          break;
        case "wechat":          
          messageBizService.sendWechat(messageChannel);
          break;
        case "ui":
          messageBizService.sendUI(messageChannel);
          break;  
        default:
          
      }
      //messageBizService.onMessage((BaseMessage)obj);
    }
    else {
      unhandled(obj);
    }    
  }

  
  

}
